package com.arcaneshift.security.errors;

import com.common.security.abstracts.AbstractError;

/**
 * Error code range: 101 - 120
 * 
 * @author Ady
 *
 */
public class PlayerError extends AbstractError {

	public static final int QUEUE_PLAYER_NOT_FOUND = 101;
	private static final String MESSAGE_QUEUE_PLAYER_NOT_FOUND = "The player was not found in the queue";
	private static final String CAUSE_QUEUE_PLAYER_NOT_FOUND = "The player may have not registered for the queue or is already in a game";
	private static final String DESCRIPTION_QUEUE_PLAYER_NOT_FOUND = "Check if there is a game with this player and if not, try to register for the queue";
	
	public static final int PLAYER_ALREADY_IN_QUEUE = 102;
	private static final String MESSAGE_PLAYER_ALREADY_IN_QUEUE = "The player is already registered in the queue";
	private static final String CAUSE_PLAYER_ALREADY_IN_QUEUE = "The player joined the queue and didn't yet left";
	private static final String DESCRIPTION_PLAYER_ALREADY_IN_QUEUE = "Cancel the current queue or keep it.";
	
	public static final int PLAYER_ALREADY_IN_GAME = 103;
	private static final String MESSAGE_PLAYER_ALREADY_IN_GAME = "The player is already in a game.";
	private static final String CAUSE_PLAYER_ALREADY_IN_GAME = "The player started a game without leaving yet.";
	private static final String DESCRIPTION_PLAYER_ALREADY_IN_GAME = "Continue the currend game or surrender to your opponent.";
	
	public PlayerError(int code) {
		super(code);
		
		switch (code) {
			case QUEUE_PLAYER_NOT_FOUND: {
				setMessage(MESSAGE_QUEUE_PLAYER_NOT_FOUND);
				setCause(CAUSE_QUEUE_PLAYER_NOT_FOUND);
				setDescription(DESCRIPTION_QUEUE_PLAYER_NOT_FOUND);
				break;
			}
			case PLAYER_ALREADY_IN_QUEUE: {
				setMessage(MESSAGE_PLAYER_ALREADY_IN_QUEUE);
				setCause(CAUSE_PLAYER_ALREADY_IN_QUEUE);
				setDescription(DESCRIPTION_PLAYER_ALREADY_IN_QUEUE);
				break;
			}
			case PLAYER_ALREADY_IN_GAME: {
				setMessage(MESSAGE_PLAYER_ALREADY_IN_GAME);
				setCause(CAUSE_PLAYER_ALREADY_IN_GAME);
				setDescription(DESCRIPTION_PLAYER_ALREADY_IN_GAME);
				break;
			}
		}
	}
}
